<template>
    <div class="item-rec">
            <div class="seckill-title">
                <p>单品推荐</p>
            </div>
            <div class="item-box">

                <div 
                class="item-box-content" 
                v-for="(item,index) in recArr"
                :key="index"
                @click="gotoGoodsDetail(item)"
                >
                    <div class="item-box-content-image">
                        <img :src="item.url" alt="">
                    </div>
                    <div class="item-box-content-title">
                        <p>{{item.desc}}</p>
                    </div>
                    <div class="item-box-content-price">
                        <p>￥{{item.price}}</p>
                        <img
                            src="../../../assets/images/al-icon-cart.png"
                            alt=""
                            class="iconImg"
                        />
                    </div>
                </div>
                


            </div>
        </div>
</template>

<script>
import api from "../../../api";
export default { 
    inject:['reload','demo'],
    name:'ShoppingRec',
    data(){
        return{
            
        }
    },
    methods:{
        gotoGoodsDetail(item){
            this.reload(); 
            //console.log(this.demo);
            console.log(item);
            this.$router.push({
                name:'Goods',
                params:{
                    obj:item
                }
            });
        }
    },
    mounted(){
        
    },
    props:{
        recArr:{
            type:Array,
            default:()=>{
                return []
            }
        }
    }
}
</script>

<style lang='less' scoped>

.item-rec{
    width: 100%;
    min-height: 291px;
    padding-top: 15px;
}
.seckill-title{
    width:80px;
    height: 23px;
    text-align: center;
    line-height: 23px;
    margin: 0 auto;
    margin-bottom: 13px;
}
.seckill-title p{
    font-size: 16px;
    font-family: Arial;
    color: rgba(16, 16, 16, 1)
}
.item-box{
    width: 100%;
    height: 530px;
    display: flex;
    flex-wrap: wrap;
}
.item-box-content{
    flex: 0 0 47%;
    height: 260px;
    margin:0 5px;
    background-color: white;
}
.item-box-content-image{
    width: 176px;
    height: 155px;
    float: right;
    margin-bottom: 8px;
}
.item-box-content-image img{
    width: 100%;
    height: 100%;
}
.item-box-content-title{
    width: 162px;
    height: 40px;
    line-height: 20px;
    text-align: left;
    overflow : hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 16px;
    p{
        color: rgba(16, 16, 16, 1);
        font-size: 14px;
        font-family: Arial;
    }
}
.item-box-content-price{
    width: 162px;
    height: 31px;
    position: relative;
    p{
        line-height: 31px;
        color: rgba(111, 68, 138, 1);
        font-size: 14px;
        text-align: left;
        font-family: Arial;
    }
    img{
        width: 25px;
        height: 25px;
        position: absolute;
        right: 0;
        top: 0;
    }
}
</style>
